package com.senter.data.dbflow.db.dao;

import com.raizlabs.android.dbflow.sql.language.OrderBy;
import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.senter.data.dbflow.model.Person;

import java.util.List;

public class PersonDao {

    public List<Person> selectList(int offset, int limit, OrderBy orderBy) {
        List<Person> personList = null;
        try {
            if (offset <= 0) {
                offset = 0;
            }
            if (limit <= 0) {
                limit = 100;
            }
            if (orderBy == null) {
                personList = SQLite.select().from(Person.class).offset(offset).limit(limit).queryList();
            } else {
                personList = SQLite.select().from(Person.class).offset(offset).limit(limit).orderBy(orderBy).queryList();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return personList;
    }
}
